package example.xmlTranslation.dataObject;

import java.util.Vector;

import example.objetRecette.Ingredient;

/**
 * @author alex
 *
 */
public class ListeIngredients {
	private Vector<Ingredient> listeIngredient;

	/**
	 * 
	 */
	public ListeIngredients() {
		this.listeIngredient = new Vector<Ingredient>();
	}

	/**
	 * @param i
	 */
	public void addIngredient(final Ingredient i) {
		this.listeIngredient.add(i);
	}

	/**
	 * @return
	 */
	public Ingredient[] getListeIngredients() {
		final Ingredient[] liste = new Ingredient[this.listeIngredient.size()];
		for (int i = 0; i < this.listeIngredient.size(); i++)
			liste[i] = this.listeIngredient.get(i);

		return liste;
	}

	/**
	 * @param listeIngredients
	 */
	public void setListeIngredients(final Vector<Ingredient> listeIngredients) {
		this.listeIngredient = listeIngredients;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return toString(0);
	}

	/**
	 * @param space
	 * @return
	 */
	public String toString(final int space) {
		String retour = "";
		String esp = "";
		for (int j = 0; j < space; j++)
			esp += " ";

		retour += esp + "* Liste ingredients :\n";

		for (Ingredient i : this.listeIngredient) {
			retour += esp + " - " + i.getNom() + " : " + i.getQuantite() + " "
					+ i.getDimension() + "\n";
		}
		return retour;
	}
}
